\documentclass[tikz,border=5pt]{standalone}
\usepackage{pgfplots}
\pgfplotsset{compat=1.18}
\usepackage{amsmath}

\begin{document}
	
	\begin{tikzpicture}
		\begin{axis}[
			axis lines = center,
			xlabel = $x$,
			ylabel = $y$,
			xmin = -pi/4, xmax = pi,    % 修改x轴范围
			ymin = -0.5, ymax = 1.5,    % 修改y轴范围
			grid = both,
			grid style = {dashed, gray!30},
			width = 12cm,
			height = 8cm,
			% 添加x=-π/4刻度，保持原有刻度
			xtick = {-pi/4, 0, 0.5*pi, pi},
			xticklabels = {$-\dfrac{\pi}{4}$, $0$, $\dfrac{\pi}{2}$, $\pi$},
			% 添加y=-0.5刻度，保持原有刻度
			ytick = {-0.5,0,0.5,1,1.5},
			every axis plot/.append style={thick},
			legend style={
				at={(1.02,0.5)},
				anchor=west,
				draw=none,
				row sep=1em,
				legend cell align=left
			}
			]
			
			% 正弦函数 y=sin(x) - 虚线（扩展定义域）
			\addplot [domain=-pi/4:pi, samples=100, black, densely dotted] {sin(deg(x))};
			\addlegendentry{$y = \sin x$}
			
			% 一阶近似 y=x - 实线（扩展定义域）
			\addplot [domain=-pi/4:pi, samples=100, red!80!black, solid] {x};
			\addlegendentry{$y = x$}
			
			% 三阶近似 y=x - x^3/6 - 实线（扩展定义域）
			\addplot [domain=-pi/4:pi, samples=100, blue!80!black, solid] {x - (x^3)/6};
			\addlegendentry{$y = x - \dfrac{1}{6}x^{3}$}
			
			% 五阶近似 y=x - x^3/6 + x^5/120 - 实线（扩展定义域）
			\addplot [domain=-pi/4:pi, samples=100, green!80!black, solid] {x - (x^3)/6 + (x^5)/120};
			\addlegendentry{$y = x - \dfrac{1}{6}x^{3} + \dfrac{1}{120}x^{5}$}
			
			% 原点标注保持不变
			\node[below left] at (0,0) {$O$};
			
			% 坐标刻度保持不变（已通过xtick/ytick设置）
			% 移除原有的额外标注，避免重复
			
		\end{axis}
	\end{tikzpicture}
	
\end{document}